//
//  ZFNavigationController.swift
//  WeiBoAPP
//
//  Created by 张学飞 on 2018/12/28.
//  Copyright © 2018 zxf. All rights reserved.
//

import UIKit

class ZFNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
//隐藏NavigationBar
        navigationBar.isHidden = true
        
        
        
        
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        print(viewController)
        
        if childViewControllers.count > 0{
            viewController.hidesBottomBarWhenPushed = true
            
            if let vc = viewController as?ZFBaseViewController {
                
                var   title = "返回"
                //判断控制器的级数
                if childViewControllers.count == 1 {
                    title = viewControllers.first?.title ?? "返回"
                }
                
                vc.navItem.leftBarButtonItem = UIBarButtonItem(title: title, target: self, action: #selector(popToParent),isBack:true)
            }
        }
        
       
        
        //隐藏底部tabbar
        super.pushViewController(viewController, animated: animated)
    }
    
    @objc private func popToParent()
    {
        popViewController(animated: true)
    }
    
}
